package com.cx.controller.zsj;


import com.cx.service.lq.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("register")
public class RegisterController {
    @Autowired
    private UserService userService;

    @RequestMapping("toregister")
    public String toregister(){
        return "register";
    }

    /**
     * 注册
     * @return
     */
    @RequestMapping("register")
    @ResponseBody
    public String register(String userName,String userPassword,String userPhone){
        int affect =  userService.register(userName,userPassword,userPhone);
       if (affect > 0) {
           return "success";
       }
       else {
           return "fail";
       }
    }

    @RequestMapping("exist")
    @ResponseBody
    public String existUser(String userName){
        int affect = userService.selectUserName(userName);
        if (affect>0)
            return "exist";
        else
            return "fail";
    }
}
